package com.woniuxy.amusementparkos.controller.wyh;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.woniuxy.amusementparkos.entity.wyh.Balance_Change;
import com.woniuxy.amusementparkos.entity.wyh.PageBean;
import com.woniuxy.amusementparkos.entity.wyh.WristStrap_Info;
import com.woniuxy.amusementparkos.service.wyh.Balance_ChangeService;
import com.woniuxy.amusementparkos.service.wyh.WristStrap_InfoService;

@Controller
public class Balance_ChangeController {
	@Autowired
	WristStrap_InfoService wristStrap_InfoService;
	@Autowired
	Balance_ChangeService balance_ChangeService;
	
	
	//获得所有该正在使用状态腕带的账户变动信息
		@ResponseBody
		@RequestMapping("/allBalanceChange")
		public Object getallBalanceChange(String wriststrp_id) {

			//System.out.println(wriststrp_id);
			
			//根据腕带信息编号 查询当前正在使用的腕带；
			WristStrap_Info workStateWristStrap = wristStrap_InfoService.getWorkStateWristStrap(wriststrp_id);
			
			if (workStateWristStrap==null) {
				//信息不存在
				return null;
			}
			
			//根据该腕带info_id查询所有变动项目
			List<Balance_Change> byInfoid = balance_ChangeService.getByInfoid(workStateWristStrap.getInfo_id());
			
			
			if(byInfoid.size()==0) {
				//没有相关信息
				return null;
			}
			
			System.out.println("所有的变动信息------"+byInfoid);
			return byInfoid;
		}
	
	
	
	//显示该正在使用状态腕带的分页账户变动信息
	@ResponseBody
	@RequestMapping("/balanceChange")
	public Object getChanges(String wriststrp_id,Integer pageNum,Integer size) {
		
		if(pageNum==null) {
			
			pageNum=1;
		}
		
		System.out.println("分页controller腕带编号-----"+wriststrp_id);
		System.out.println("分页controller页码号-----"+pageNum);
		//根据腕带信息编号 查询当前正在使用的腕带；
		WristStrap_Info workStateWristStrap = wristStrap_InfoService.getWorkStateWristStrap(wriststrp_id);
		
		if (workStateWristStrap==null) {
			//信息不存在
			return null;
		}
		
		//根据该腕带info_id查询所有变动项目
		PageBean<Balance_Change> pagebeanByInfoid = balance_ChangeService.getPagebeanByInfoid(workStateWristStrap.getInfo_id(), pageNum,size);
		
		if(pagebeanByInfoid.getBeanList().size()==0) {
			//没有相关信息
			return null;
		}
		
		System.out.println("pagebean------"+pagebeanByInfoid);
		return pagebeanByInfoid;
		
	}
}
